package com.lxb.mqttdemo

import android.os.Parcel
import android.os.Parcelable

/**
 * Created by lion on 2018/2/26.
 */

data class Car(
		val name: String,
		val id: Int,
		val nickname: String
) : Parcelable {
	constructor(source: Parcel) : this(
			source.readString(),
			source.readInt(),
			source.readString()
	)

	override fun describeContents() = 0

	override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
		writeString(name)
		writeInt(id)
		writeString(nickname)
	}

	companion object {
		@JvmField
		val CREATOR: Parcelable.Creator<Car> = object : Parcelable.Creator<Car> {
			override fun createFromParcel(source: Parcel): Car = Car(source)
			override fun newArray(size: Int): Array<Car?> = arrayOfNulls(size)
		}
	}
}